Also scroll horizontally when necessary, and keep the northwest corner of
authorMatthias Clasen <mclasen@redhat.com>
Fri, 29 Apr 2005 16:20:07 +0000 (16:20 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Fri, 29 Apr 2005 16:20:07 +0000 (16:20 +0000)
2005-04-29  Matthias Clasen  <mclasen@redhat.com>

* gtk/gtkiconview.c (gtk_icon_view_scroll_to_item): Also
scroll horizontally when necessary, and keep the northwest
corner of the item visible.  (#300913, Mathias Hasselmann)

ChangeLog
ChangeLog.pre-2-10
ChangeLog.pre-2-8
gtk/gtkiconview.c

index 759bc0401012dd6839f2629565b366877b4320b1..b00a5d94149dd98f7a59b69e83acd7eac7e7a235 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2005-04-29  Matthias Clasen  <mclasen@redhat.com>
 
+       * gtk/gtkiconview.c (gtk_icon_view_scroll_to_item): Also
+       scroll horizontally when necessary, and keep the northwest
+       corner of the item visible.  (#300913, Mathias Hasselmann)
+
        * tests/testiconview.c: Add some more tests.
 
        * gtk/gtkiconview.c (gtk_icon_view_select_path): Don't crash
index 759bc0401012dd6839f2629565b366877b4320b1..b00a5d94149dd98f7a59b69e83acd7eac7e7a235 100644 (file)
@@ -1,5 +1,9 @@
 2005-04-29  Matthias Clasen  <mclasen@redhat.com>
 
+       * gtk/gtkiconview.c (gtk_icon_view_scroll_to_item): Also
+       scroll horizontally when necessary, and keep the northwest
+       corner of the item visible.  (#300913, Mathias Hasselmann)
+
        * tests/testiconview.c: Add some more tests.
 
        * gtk/gtkiconview.c (gtk_icon_view_select_path): Don't crash
index 759bc0401012dd6839f2629565b366877b4320b1..b00a5d94149dd98f7a59b69e83acd7eac7e7a235 100644 (file)
@@ -1,5 +1,9 @@
 2005-04-29  Matthias Clasen  <mclasen@redhat.com>
 
+       * gtk/gtkiconview.c (gtk_icon_view_scroll_to_item): Also
+       scroll horizontally when necessary, and keep the northwest
+       corner of the item visible.  (#300913, Mathias Hasselmann)
+
        * tests/testiconview.c: Add some more tests.
 
        * gtk/gtkiconview.c (gtk_icon_view_select_path): Don't crash
index 568e9ca9a0ee8898276ca6deb86f1886c1dccd7b..08d195206abcae5de70651939b97917226ea8a24 100644 (file)
@@ -3000,11 +3000,11 @@ static void
 gtk_icon_view_scroll_to_item (GtkIconView     *icon_view, 
                              GtkIconViewItem *item)
 {
-  gint y, height;
+  gint x, y, width, height;
   gdouble value;
 
-  gdk_drawable_get_size (GDK_DRAWABLE (icon_view->priv->bin_window), NULL, &height);
-  gdk_window_get_position (icon_view->priv->bin_window, NULL, &y);
+  gdk_drawable_get_size (GDK_DRAWABLE (icon_view->priv->bin_window), &width, &height);
+  gdk_window_get_position (icon_view->priv->bin_window, &x, &y);
 
   if (y + item->y < 0)
     {
@@ -3015,8 +3015,22 @@ gtk_icon_view_scroll_to_item (GtkIconView     *icon_view,
     {
       value = icon_view->priv->vadjustment->value + y + item->y + item->height 
        - GTK_WIDGET (icon_view)->allocation.height;
+      value = MIN (value, icon_view->priv->vadjustment->value + y + item->y);
       gtk_adjustment_set_value (icon_view->priv->vadjustment, value);
     }
+
+  if (x + item->x < 0)
+    {
+      value = icon_view->priv->hadjustment->value + x + item->x;
+      gtk_adjustment_set_value (icon_view->priv->hadjustment, value);
+    }
+  else if (x + item->x + item->width > GTK_WIDGET (icon_view)->allocation.width)
+    {
+      value = icon_view->priv->hadjustment->value + x + item->x + item->width 
+       - GTK_WIDGET (icon_view)->allocation.width;
+      value = MIN (value, icon_view->priv->hadjustment->value + x + item->x);
+      gtk_adjustment_set_value (icon_view->priv->hadjustment, value);
+    }
 }
 
 /* Public API */